from aiogram import Router
from aiogram.filters import Command
from db import session, BotUser

router = Router()


@router.message(Command("people"))
async def show_all(message):
    recs = session.query(BotUser).order_by(BotUser.username).all()
    print(recs)
    if len(recs) != 0:
        mess = "📜 Список пользователей:\n\n"
        for item in recs:
            mess = (
                mess
                + f"🔹<em>{item.username} - {item.birthday.strftime('%d-%m-%Y')}</em>\n\n"
            )

        await message.answer(mess)

    else:
        await message.answer(text="❗Еще нет добавленных пользователей...")
